//
//  BJDeleteAccountView.m
//  
//
//  Created by lishen on 2023/5/19.
//  Copyright © 2023 lishen. All rights reserved.
//

#import "BJDeleteAccountView.h"

@interface BJDeleteAccountView()
@property (nonatomic,strong)UIView *contentView;
@property (nonatomic,strong)UILabel *titleLabel;
@property (nonatomic,strong)UIImageView *cancelImgView;
@property (nonatomic,strong)UILabel *contentLabel;

@property (nonatomic,strong)UILabel *cancelLabel;
@end

@implementation BJDeleteAccountView

-(instancetype)initWithFrame:(CGRect)frame{
    if(self = [super initWithFrame:frame]){
        self.backgroundColor = [UIColor colorWithHexString:@"#000000" alpha:0.15];
        [self setupSubviews];
    }
    return self;
}
- (void)setupSubviews{
    self.addChild(self.contentView);
    self.contentView.addChild(self.titleLabel);
    self.contentView.addChild(self.cancelImgView);
    self.contentView.addChild(self.contentLabel);
    self.contentView.addChild(self.confirmLabel);
    self.contentView.addChild(self.cancelLabel);
    self.contentView.makeCons(^{
        make.centerX.centerY.constants(0);
        make.leading.constants(20);
        make.trailing.constants(-20);
    });
    self.titleLabel.makeCons(^{
        make.top.constants(40);
        make.trailing.leading.centerX.constants(0);
    });
    self.cancelImgView.makeCons(^{
        make.trailing.constants(-12);
        make.top.constants(12);
        make.width.height.constants(20);
    });
    self.contentLabel.makeCons(^{
        make.centerX.constants(0);
        make.leading.constants(37);
        make.trailing.constants(-37);
        make.top.view(self.titleLabel).bottom.constants(16);
    });
    self.confirmLabel.makeCons(^{
        make.centerX.constants(0);
        make.top.view(self.contentLabel).bottom.constants(28);
        make.height.constants(44);
        make.leading.constants(16);
        make.trailing.constants(-16);
    });
    self.cancelLabel.makeCons(^{
        make.centerX.constants(0);
        make.top.view(self.confirmLabel).bottom.constants(10);
        make.bottom.constants(-20);
    });
    self.contentView.layer.cornerRadius = 16;
    self.contentView.layer.masksToBounds = YES;
    self.contentView.backgroundColor = UIColor.whiteColor;
    self.cancelImgView.onClick(^{
        [self removeFromSuperview];
    });
    self.cancelLabel.onClick(^{
        [self removeFromSuperview];
    });
}

- (UIView *)contentView{
    AsGetMethodReturnObjc(_contentView);
    _contentView = View;
    return _contentView;
}
- (UILabel *)titleLabel{
    AsGetMethodReturnObjc(_titleLabel);
    _titleLabel = Label;
    _titleLabel.text = @"Confirm to delete account?";
    _titleLabel.textColor = [UIColor colorWithHexString:@"#1A1A1A"];
    _titleLabel.textAlignment = NSTextAlignmentCenter;
    _titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:20];
    _titleLabel.numberOfLines = 0;
    return _titleLabel;
}
- (UIImageView *)cancelImgView{
    AsGetMethodReturnObjc(_cancelImgView);
    _cancelImgView = ImageView;
    [_cancelImgView setImage:[UIImage imageNamed:@"ic_msgpop_close"]];
    return _cancelImgView;
}
- (UILabel *)contentLabel{
    AsGetMethodReturnObjc(_contentLabel);
    _contentLabel = [[UILabel alloc]init];
    _contentLabel.text = @"Are you sure you want to delete your account?";
    _contentLabel.numberOfLines = 0;
    _contentLabel.textAlignment = NSTextAlignmentCenter;
    _contentLabel.textColor = [UIColor colorWithHexString:@"#656666"];
    return _contentLabel;
}
- (UILabel *)confirmLabel{
    AsGetMethodReturnObjc(_confirmLabel);
    _confirmLabel = Label;
    _confirmLabel.text = @"Confirm";
    _confirmLabel.textColor = UIColor.whiteColor;
    _confirmLabel.textAlignment = NSTextAlignmentCenter;
    _confirmLabel.layer.cornerRadius = 22;
    _confirmLabel.layer.masksToBounds = YES;
    _confirmLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:17];
    _confirmLabel.backgroundColor = [UIColor colorWithHexString:@"#3CFCE8"];
    return _confirmLabel;
}
- (UILabel *)cancelLabel{
    AsGetMethodReturnObjc(_cancelLabel);
    _cancelLabel = Label;
    _cancelLabel.text = @"Cancel";
    _cancelLabel.textColor = [UIColor colorWithHexString:@"#979999"];
    _cancelLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:17];
    return _cancelLabel;
}
@end
